﻿using System;
using System.Collections.Generic;

namespace InfiniTec.Exchange.Notifications
{
	/// <summary>
	/// The IExchangeWebServicesAdapter specifies the contract for an adapter which allows a <see cref="Subscription"/> to register itself with
	/// an Exchange 2007 Server or later.
	/// </summary>
	public interface IExchangeWebServicesAdapter
	{
		/// <summary>
		/// Creates a push subscription on an Exchange 2007 server.
		/// </summary>
		/// <param name="folders">A list of references to folders to monitor for changes.</param>
		/// <param name="events">A valid combination of the <see cref="EventTypes"/> values, except for <see cref="EventTypes.None"/>.</param>
		/// <param name="lastKnownWatermark">The last known watermark. Exchange will resent changes which occured after the date specified by the watermark. A watermark is valid for about 30 days (Exchange 2007).</param>
		/// <param name="timeoutIntervalInMinutes">The timeout interval in minutes. A subscriptions is to be considered timed-out when no status message or other event happend for a timespan twice as long as the timeout interval.</param>
		/// <param name="localEndpoint">The local endpoint of a <see cref="PushNotificationListener"/>.</param>
		/// <returns>A <see cref="SubscriptionInfo"/> containing the subscription id and an initial watermark.</returns>
		SubscriptionInfo Subscribe(IEnumerable<FolderReference> folders, EventTypes events, string lastKnownWatermark, int timeoutIntervalInMinutes, Uri localEndpoint);

		/// <summary>
		/// Creates a pull subscription on an Exchange 2007 server.
		/// </summary>
		/// <param name="folders">A list of references to folders to monitor for changes.</param>
		/// <param name="events">A valid combination of the <see cref="EventTypes"/> values, except for <see cref="EventTypes.None"/>.</param>
		/// <param name="lastKnownWatermark">The last known watermark. Exchange will resent changes which occured after the date specified by the watermark. A watermark is valid for about 30 days (Exchange 2007).</param>
		/// <param name="timeoutIntervalInMinutes">The timeout interval in minutes. A subscriptions is to be considered timed-out when no status message or other event happend for a timespan twice as long as the timeout interval.</param>
		/// <returns>A <see cref="SubscriptionInfo"/> containing the subscription id and an initial watermark.</returns>
		SubscriptionInfo Subscribe(IEnumerable<FolderReference> folders, EventTypes events, string lastKnownWatermark, int timeoutIntervalInMinutes);
	
		/// <summary>
		/// Cancels a pull subscription on an Exchange 2007 server.
		/// </summary>
		/// <param name="subscriptionId">The id of the subscription to cancel</param>
		void Unsubscribe(string subscriptionId);

		IEnumerable<EventInfo> GetEvents(string subscriptionId, string watermark);
	}
}
